<?php
/**
 * Created by PhpStorm.
 * User: administrator
 * Date: 2016/7/30 0030
 * Time: 10:06
 */
namespace Home\Controller;
use Think\Controller;

//用户中心全局控制
class OrderflowController extends  Controller{

    public function default_consignee(){


        $user_id=empty($_SESSION['user_id'])?0:intval($_SESSION['user_id']);
        $address_id=M('users')->where(array('user_id'=>$user_id))->getField('address_id');

        $user_address=M('user_address')->where(array('address_id'=>$address_id))->find();

        $arr['a']=$user_address['consignee'];
        $arr['b']=$user_address['tel'];
        $arr['c']=$user_address['idcard'];
        $arr['d']=$user_address['address'];
        $arr['e']=$user_address['zipcode'];
        $arr['f']=$user_address['mobile'];
        $arr['status']=1;
        echo json_encode($arr);
        exit;
    }

    public function default_send(){
        
    }

    public function pre_deposit_alipay_save(){

        $money= I('money');
        if(empty($money)){
            echo json_encode(array('status'=>0,'info'=>'请输入转账金额'));
            exit;
        }

       
        $remark= I('remark');
        $reference = I('reference');

        //插入充值记录
        $add_data['user_id']=$_SESSION['user_id'];
        $add_data['money']=$money;
        $add_data['pay_fee'] = pay_fee(8, $money);
        $add_data['add_time']=time();
        $add_data['is_checked']=0;
        $add_data['remark']=$remark;
        $add_data['check_user']=0; //默认显示全部
        $add_data['check_remark']='';
        $add_data['check_time']=0;
        $add_data['reference']=$reference;
        $add_data['pay_type']=2;

        $record_id=M('user_pre_deposit_record')->data($add_data)->add();

        $pay_order['order_id']=$record_id;
        $pay_order['order_amount']=$money;
        $pay_order['pay_fee'] = pay_fee(8, $money);
        $pay_order['order_type']=1;
        $pay_order['is_paid']=0;

        $pay_log_id=M('pay_log')->data($pay_order)->add();

        echo json_encode(array('status'=>1,'info'=>'提交成功，请立即支付','pay_log_id'=>$pay_log_id));
        exit;

    }

}